package com.iron.common.feign.config;

import com.alibaba.cloud.sentinel.feign.SentinelFeign;
import com.iron.common.feign.logger.IronFeignLogger;
import feign.Feign;
import feign.Logger;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;

/**
 * feign 配置类
 *
 * @author YT
 * @date 2019-06-11
 */
@Configurable
public class IronFeignConfiguration {

    /**
     * 使用自定义 feign client 客户端
     * 注意：在使用 SentinelFeign.builder() 来创建 SentinelFeign 客户端作为 Feign 客户端
     *
     * @return
     */
    @Bean
    public Feign.Builder client() {
        return SentinelFeign.builder().client(new IronFeignClient());
    }

    /**
     * feign.compression.request.enabled=true
     * feign.compression.response.enabled=true
     */

    /**
     * 使用自定义 feign logger 配置
     *
     * @return
     */
    @Bean
    public Logger ironFeignLogger() {
        return new IronFeignLogger();
    }

    /**
     * 配置 feign 日志打印等级
     *
     * @return
     */
    @Bean
    public Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

}
